home *** CD-ROM | disk | FTP | other *** search
- unit ParentMainFormUnit;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Menus, StdCtrls, ExtCtrls;
-
- type
- TParentForm = class(TForm)
- Timer1: TTimer;
- Memo1: TMemo;
- MainMenu1: TMainMenu;
- LaunchChildApp1: TMenuItem;
- procedure LaunchChildApp1Click(Sender: TObject);
- public
- procedure WMCopyData(var Msg: TWMCopyData);
- message wm_CopyData;
- end;
-
- {$ifdef Ver90}
- //This exception class did not exist until Delphi 3
- EWin32Error = class(Exception);
- {$endif}
-
- var
- ParentForm: TParentForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TParentForm.LaunchChildApp1Click(Sender: TObject);
- const
- ChildApp = 'Child.Exe';
- var
- SI: TStartupInfo;
- PI: TProcessInformation;
- begin
- GetStartupInfo(SI);
- if not CreateProcess(nil, PChar(ChildApp + ' ' + IntToStr(Handle)), nil,
- nil, False, 0, nil, nil, SI, PI) then
- raise EWin32Error.Create('Unable to launch ' + ChildApp);
- end;
-
- procedure TParentForm.WMCopyData(var Msg: TWMCopyData);
- var
- TextMsg: String;
- begin
- //Set the string variable length and content to match what was sent
- SetString(TextMsg, PChar(Msg.CopyDataStruct^.lpData), Msg.CopyDataStruct^.cbData);
- //Put string into memo
- Memo1.Text := TextMsg
- end;
-
- end.
-